<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>


<html>
  <head>
  	 <script type='text/javascript' src='/HR_Sys/dwr/interface/JuserBiz.js'></script>
 	 <script type='text/javascript' src='/HR_Sys/dwr/engine.js'></script>
 	 <script type='text/javascript' src='/HR_Sys/dwr/util.js'></script>


  	
    <script type="text/javascript">
   		var issubmit=false;
  		function checkUserExists(obj)
   		{
   			issubmit=false
   			var name=obj.value;
   			var txtName=document.getElementById("divName");
   			
   			txtName.style.color="red";
	  		txtName.innerHTML="";
   			if(!name)
   			{  				
   				txtName.innerHTML="<img src='/HR_Sys/images/message_error.gif'/>用户名不能为空!";
   				
   				issubmit=false;
   				return ;
   				
  			}
   			
   			JuserBiz.isExsist(name,haoLeJiaoWo);   			
			//return false;
			
   		}
   		 
   		 function aa(obj)
   		 {
   			var issubmit=false;
   		 	var name=obj.value;
   		 	var txtName=document.getElementById("divtrueName");
   		 	txtName.style.color="red";
	   		txtName.innerHTML="";
   		 	if(!name)
   		 	{
   		 		txtName.innerHTML="<img src='/HR_Sys/images/message_error.gif'/>真实姓名不能为空!";
   		 		
   		 		issubmit=false;
   		 		return;
   		 	}
   		 }  		
   		function checkSubmit()
   		{	
   			var txtName=document.getElementById("uname");
   			var txtTrueName=document.getElementById("truename");
			return issubmit;
   		}
   		
   		function haoLeJiaoWo(b)
   		{
   			issubmit=false;
   			var txtName=document.getElementById("divName");
   			if(b==1){
   			
	  			txtName.style.color="red";
	  			txtName.innerHTML="";
   				txtName.innerHTML="<img src='/HR_Sys/images/message_error.gif'/>用户名已经存在";
   				
   				issubmit=false;
   				
   			}else if(b==0)
   			{
   				txtName.innerHTML="<img src='/HR_Sys/images/message_success.gif'/>用户名可以用";
   				issubmit=true;
   				
   			}
   		}
	   	
   </script>
    
    <title>添加用户</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    	<html:form action="user.do?op=addUser"  onsubmit="return checkSubmit()"  >
    		<table>
    			<tr>
    				<td>用户名</td>
    				<td><html:text property="user.name" styleId="uname" onblur="return checkUserExists(this)"/></td>
    				<td><div id="divName"></div></td>
    			</tr>
    			<tr>
    				<td>真实姓名</td>
    				<td><html:text property="user.trueName" styleId="truename" onblur="return aa(this)"></html:text></td>
    				<td><div id="divtrueName"></div></td>
    			</tr>
    			
    		</table>
    			<html:submit>提交</html:submit>
    			
    	</html:form>
  </body>
</html>
